# 递归函数求阶乘和
# import time
#
# start=time.time()
# print(start)
# def get_mul_sum(n):
#     if n==1:
#         return 1
#     else:
#         return get_mul(n) +get_mul_sum(n-1)
# def get_mul(n):
#     if n==1:
#         return 1
#     else:
#         return n*get_mul(n-1)
# print(get_mul_sum(5))
# end=time.time()
# print(end,end-start)

l0=[{'id':101,'name':'deng','age':20,'sex':1},
    {'id':102,'name':'zhang','age':24,'sex':0}]
def get_n(n,m):
    for e in n:
        print(m(e))
get_n(l0,lambda x:x["id"])

def my_max(dates,key):
    max_id=None
    max_0bject=None
    for e in dates:
        #print(key(e))
        if max_id is None:
            max_id=key(e)
            max_0bject=e
        else:
            if max_id<key(e):
                max_id=key(e)
                max_0bject=e
    return max_0bject
    # print(key,type(key))
print(my_max(l0,key=lambda x:x['id']))

# l0=[{'id':101,'name':'deng','age':20,'sex':1},
#     {'id':102,'name':'zhang','age':24,'sex':0}]
# def x(x):
#     return x['id']
# print(x(l0[1]))
